#include "common/defines.h"
#include "recentcontactparser.h"
#include "event/recentcontactevent.h"


RecentContactParser::RecentContactParser(QObject *parent) :
    AbstractParser(parent)
{
}


AbstractEvent *RecentContactParser::parse(const QString &commandId, const QVariant &data)
{
    int cmId = commandId.toInt();
    switch (cmId) {
    case GET_RECENT_CONTACTS:
        return parseData(data);
    default:
        return NULL;
    }
}


AbstractParser::Type RecentContactParser::type() const
{
    return AbstractParser::RecentContactType;
}


AbstractEvent *RecentContactParser::parseData(const QVariant &data)
{
    if (data.type() != QVariant::List)
        return NULL;

    QVariantList list = data.toList();

    return new RecentContactEvent(list);
}
